{{ .dataGrid }}

<div id="assets_edit_dialog" class="easyui-dialog" title="编辑资源内容"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_edit',buttons:[{text:'确定',iconCls:'icons-other-tick',handler:function(){assetsEditForm();}},{text:'取消',iconCls:'icons-arrow-cross',handler:function(){$('#assets_edit_dialog').dialog('close');}}]"
     style="width:100%;height:100%;"></div>


<div id="assets_add_dialog" class="easyui-dialog" title="添加资源内容"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_edit',buttons:[{text:'确定',iconCls:'icons-other-tick',handler:function(){assetsAddForm();}},{text:'取消',iconCls:'icons-arrow-cross',handler:function(){$('#assets_add_dialog').dialog('close');}}]"
     style="width:100%;height:100%;"></div>

<script>

    var assets_list_datagrid_toolbar = [
        {text: '添加模板', iconCls: 'icons-arrow-add', handler: assetsAddSource},
        {text: '刷新', iconCls: 'icons-arrow-arrow_refresh', handler: function () {refreshAssetsList()}},
    ];


    function assetListOpFormatter(name) {
        var btn = [];
        btn.push("<a class='btn btn-default btn-sm' href=\"javascript:;\" onclick=\"assetsEditSource('" + name + "')\">编辑</a>");
        // btn.push("<a href=\"javascript:;\" onclick=\"deleteBackupList('" + name + "')\">删除</a>");
        return btn.join(' | ');
    }

    function fileSizeFormatter(size) {
        if (size < 1024) {
            return size + "B"
        } else if (size / 1024 < 1024) {
            return (size /1024).toFixed(2) + "K"
        } else {
              return (size / (1024 ** 2)).toFixed(2) + "M"
        }
    }

    function assetsEditSource(name) {
        if (!name) return;
        var url = "/b/assets-manager/edit?name=" + name + "&type=template";
        $('#assets_edit_dialog').dialog({href: url});
        $('#assets_edit_dialog').dialog('open');
    }

    function assetsAddSource() {
        var url = "/b/assets-manager/add";
        $('#assets_add_dialog').dialog({href: url});
        $('#assets_add_dialog').dialog('open');
    }

    function refreshAssetsList() {
        $('#assets_list_datagrid').datagrid('reload');
    }

</script>
